]> git.r.bdr.sh - rbdr/super-polarity/blame - Super Polarity/Actors/Bullet.cs
I have the worst commits ever.
[rbdr/super-polarity] / Super Polarity / Actors / Bullet.cs
CommitLineData
38c7d3f9
BB
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
7
8namespace SuperPolarity
9{
10 class Bullet : Actor
11 {
12 protected ParticleEngine particleEngine;
74c15570 13 public int Power;
38c7d3f9 14
74c15570 15 public Bullet(SuperPolarity newGame)
38c7d3f9
BB
16 : base(newGame)
17 {
18 }
19
20 ~Bullet()
21 {
22 particleEngine = null;
23 }
24
25 public override void Initialize(Texture2D texture, Vector2 position)
26 {
27 base.Initialize(texture, position);
74c15570
BB
28 BoxDimensions.X = 10;
29 BoxDimensions.Y = 10;
30 BoxDimensions.W = 10;
31 BoxDimensions.Z = 10;
32 InitBox();
38c7d3f9
BB
33 particleEngine = ParticleEffectFactory.CreateBullet(position);
34 }
35
36 public override void Update(GameTime gameTime)
37 {
38 Velocity.X = (float)(MaxVelocity * Math.Cos(Angle));
39 Velocity.Y = (float)(MaxVelocity * Math.Sin(Angle));
40
74c15570
BB
41 Power = 1;
42
38c7d3f9 43 Position += Velocity;
74c15570 44 UpdateBox();
38c7d3f9
BB
45
46 particleEngine.Update();
47 particleEngine.EmitterLocation = Position;
48 }
49
50 public override void Draw(SpriteBatch spriteBatch)
51 {
52 base.Draw(spriteBatch);
53 particleEngine.Draw(spriteBatch);
54 }
74c15570
BB
55
56 public override void Collide(Actor other, Rectangle collision)
57 {
58 if (Dying) { return; }
59 if (other.GetType().IsAssignableFrom(typeof(StandardShip)))
60 {
61 Die();
62 return;
63 }
64 }
65
66 protected override void Die()
67 {
68 ActorManager.CheckOut(this);
69 Parent.Children.Remove(this);
70 }
38c7d3f9
BB
71 }
72}